<?php
$setting = array(
	'databaseHost'    => '127.0.0.1',
	'databaseUser'    => 'root',
	'databasePass'    => '',
	'oldDatabaseName' => 'ixdcw_v11',
	'newDatabaseName' => 'ixdcw_v12',
	'execute'         => false,
);
$db      = new PDO("mysql:host={$setting['databaseHost']};dbname={$setting['oldDatabaseName']}", $setting['databaseUser'], $setting['databasePass']);
$result  = $db->query("show tables");
$tables  = $result->fetchAll();
foreach ($tables as $tableCtr) {
	$tablename = $tableCtr['Tables_in_' . $setting['newDatabaseName']];
	$sql       = "ALTER TABLE $tablename RENAME TO " . str_replace('mymps', 'mk_', $tablename);
	$sql       = "RENAME TABLE {$setting['oldDatabaseName']}.{$tablename} TO {$setting['newDatabaseName']}.{$tablename};";
	if ($setting['execute']) {
		if ($db->query($sql)) {
			continue;
		} else {
			exit($db->errorInfo());
		}
	} else {
		echo $sql . PHP_EOL;
	}
}